<template>
    <div class="vehicleInfor_block">
        <div class="top">
            <search-bar v-model="searchModel" :search-data="searchData" :config="searchData" @search="handleSearchSubmit"
                @searchReset="handleSearchReset" style="margin-top:0;margin-left:-20px;padding-top:.2rem">
            </search-bar>
        </div>

        <div class="bottom">

            <div class="btn_area" size="medium">
                <el-button type="primary" size="medium" @click="add">新增</el-button>
                <el-dropdown @command="handleCommand" style="margin-left: 0.1rem">
                    <el-button size="medium">
                        批量操作<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">


                        <el-dropdown-item command="import">启用</el-dropdown-item>
                        <el-dropdown-item command="export">禁用</el-dropdown-item>
                        <el-dropdown-item command="delete">删除</el-dropdown-item>

                    </el-dropdown-menu>
                </el-dropdown>
                <el-button type="" size="medium" style="margin-left: 0.1rem" @click="exportWay">导出</el-button>
            </div>
            <LPTablePage :show-index="true" :table-data="tableData" :table-column="tableColumn" :total="total"
                :current-page="currentPage" @handleSizeChange="handleSizeChange" @handleCurrentChange="handleCurrentChange"
                :selection="true" @handleSelectionChange="handleSelectionChange" ref="tablePage" :selectable="selectable">
                <template slot="relate" slot-scope="scope">
                    <span v-if="scope.row.relate == 1">
                        临时
                    </span>
                    <span v-else>
                        自有
                    </span>
                </template>
                <template slot="reviewStatus" slot-scope="scope">
                    <div v-if="scope.row.reviewStatus == 0" >
                        <ProcessDots :processStatus="'checkPending'"/>待审核
                    </div>
                    <div v-else-if="scope.row.reviewStatus == 1" >
                        <ProcessDots :processStatus="'finished'"/>已通过
                    </div>
                    <div v-else >
                        <ProcessDots :processStatus="'rejected'"/>已驳回
                    </div>
                   
                </template>
                <!--  -->
                <template slot="vehicleStatus" slot-scope="scope">
                    <div v-if="scope.row.vehicleStatus == 0" >
                        <ProcessDots :processStatus="'rejected'"/>停用
                    </div>
                    <div v-else-if="scope.row.vehicleStatus == 1" >
                        <ProcessDots :processStatus="'finished'"/>可用
                    </div>

                </template>
                <template slot="emissionStandard" slot-scope="scope">
                    <div>
                        {{ showByDict('emissionStandard',scope.row.emissionStandard) }}
                    </div>
                </template>
                <template slot="usageType" slot-scope="scope">
                    <div>
                        {{ showByDict('usageType',scope.row.usageType) }}
                    </div>
                </template>
                <template slot="vehicleColor" slot-scope="scope">
                    <div>
                        {{ showByDict('vehicleColor',scope.row.vehicleColor) }}
                    </div>
                </template>
                <template slot="drivingVehicleType" slot-scope="scope">
                    <div>
                        {{ showByDict('drivingVehicleType',scope.row.drivingVehicleType) }}
                    </div>
                </template>
                <template slot="vehicleType" slot-scope="scope">
                    <div>
                        {{ showByDict('vehicleType',scope.row.vehicleType) }}
                    </div>
                </template>
                <template slot="networkStatus" slot-scope="scope">
                    <span v-if="scope.row.networkStatus == 0">
                        未联网
                    </span>
                    <span v-else-if="scope.row.networkStatus == 1">
                        已联网
                    </span>
                </template>
                <template slot="isContainer" slot-scope="scope">
                    <span v-if="scope.row.isContainer == 0">
                        否
                    </span>
                    <span v-else-if="scope.row.isContainer == 1">
                        是
                    </span>
                </template>
                
                <template slot="isActive" slot-scope="scope">

                    <el-switch v-model="scope.row.isActive" :active-value="1" :inactive-value="0"></el-switch>
                </template>


            </LPTablePage>
        </div>
        <!-- 编辑or新增 -->
        <base-dialog :visible="addVisile" :title="(isEdit ? '编辑' : '新增') + '物流公司'" width="918px" class="addDictDialog"
            @handleDialogSubmit="handleAddSubmit" @handleDialogCancle="handleAddCancle">
            <el-form ref="dictForm" :model="dictModel" :rules="dictRule" label-width="120px" class="dictForm"
                label-position="top" size="medium">
                <el-row :gutter="50">

                    <el-col :span="12">
                        <el-form-item label="物流公司名称:" prop="dictValue">
                            <el-input v-model.trim="dictModel.dictValue" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="物流公司编号:" prop="dictValue">
                            <el-input v-model.trim="dictModel.dictValue" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="统一社会信用代码:" prop="remark">
                            <el-input v-model="dictModel.remark" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="法人:" prop="remark">
                            <el-input v-model="dictModel.remark" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="所在区域:" prop="remark">
                            <el-input v-model="dictModel.remark" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="详细地址:" prop="remark">
                            <el-input v-model="dictModel.remark" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="关联用户帐号:" prop="systemType">
                            <el-select style="width:100%" v-model="dictModel.systemType" placeholder="关联用户帐号" filterable>
                                <el-option v-for="(item, index) in systemOptions" :key="index" :value="item.value"
                                    :label="item.label" />
                            </el-select>
                            <!-- <el-input  v-model="dictModel.system" readonly></el-input> -->

                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="是否启用:" prop="status">

                            <el-switch v-model="dictModel.status" />
                            <span class="ml20">关闭后物流公司在系统停止使用</span>

                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </base-dialog>
        <!-- 审核 -->
        <base-dialog :visible="auditVisile" title="审核" width="640px" class="addDictDialog"
            @handleDialogSubmit="handleAuditSubmit" @handleDialogCancle="handleAuditCancle">
            <el-form ref="auditParams" :model="auditParams" :rules="dictRule" label-width="120px" class="dictForm"
                label-position="top" size="medium">
                <el-row :gutter="50">

                    <el-col :span="24">
                        <el-form-item label="审核结果:" prop="reviewStatus">
                            <el-radio-group v-model="auditParams.reviewStatus">

                                <el-radio :label="1">通过</el-radio>
                                <el-radio :label="2">驳回</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="审核说明:" prop="">
                            <el-input v-model.trim="auditParams.reviewDescribe" type="textarea" :rows="2" placeholder="请输入">
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </base-dialog>
    </div>
</template>
    
<script>
import { validateNumber } from "@/utils/validate";
import baseDialog from '@/components/BaseDialog'
import SearchBar from '@/components/SearchBar'
import LPTablePage from '@/components/LPTablePage'
import ProcessDots from '@/components/ProcessDots';
import {
    logininforList,
    delLogininfor,
    cleanLogininfor
} from '@/api/system/logs'
import { addDateRange } from "@/utils/ruoyi";
import masterDataApi from '@/api/logistics/masterData'



export default {
    name: "logisticsCompany",
    components: {
        LPTablePage, SearchBar, baseDialog,ProcessDots
    },
    data() {
        const validateNumberF = (rule, value, callback) => {
            if (Number(value) == 0) {
                return callback(new Error("不能为0"));
            }
            if (!validateNumber(value)) {
                return callback(new Error("请输入正确数字"));
            } else {
                callback();
            }
        };
        const validateEmpty = (rule, value, callback) => {
            console.log('validateEmpty', value, value instanceof Array);
            if (!(value instanceof Array)) {
                return callback(new Error("必填"));
            }
            if (value instanceof Array && value.length == 0) {
                return callback(new Error("必填"));
            } else {
                callback()
            }
        };
        return {
            auditParams: {

            },
            addVisile: false,
            auditVisile: false,
            auditId: '',
            isEdit: false,
            dictModel: {

                dictValue: '',
                systemType: '',
                // items: [],
                status: '',

                remark: '',
                sysDictDataDetailList: []

            },
            searchModel: {},
            searchData: [
                {
                    placeholder: "", prop: "reviewStatus", type: 'radio',

                    options: [
                        { label: '待审核', value: 0,num:0, },
                        { label: '已通过', value: 1 ,num:0, },
                        { label: '已驳回', value: 2 ,num:0, },

                    ]
                },
                {
                    prop: 'vehicleStatus',
                    type: 'select',
                    placeholder: '车辆状态',
                    options: [
                        { label: '停用', value: '0' },
                        { label: '可用', value: '1' },

                    ]
                },
                { placeholder: "车牌号", prop: "vehicleNumber", },
                {
                    prop: 'emissionStandard',
                    type: 'select',
                    placeholder: '排放标准',
                    options: [
                        { label: '排放标准1', value: '0' },
                        { label: '排放标准2', value: '1' },

                    ]
                },
                {
                    prop: 'isActive',
                    type: 'select',
                    placeholder: '是否启用',
                    options: [
                        { label: '停用', value: '0' },
                        { label: '启用', value: '1' },

                    ]
                },
                {
                    prop: 'usageType',
                    type: 'select',
                    placeholder: '使用性质',
                    options: [
                        { label: '使用性质1', value: '0' },
                        { label: '使用性质2', value: '1' },

                    ]
                },
                {
                    prop: 'vehicleColor',
                    type: 'select',
                    placeholder: '号牌颜色',
                    options: [
                        { label: '颜色1', value: '0' },
                        { label: '颜色2', value: '1' },

                    ]
                },
                {
                    prop: 'drivingVehicleType',
                    type: 'select',
                    placeholder: '车辆类型',
                    options: [

                        { label: '车辆类型1', value: '0' },
                        { label: '车辆类型2', value: '1' },

                    ]
                },
                {
                    prop: 'networkStatus',
                    type: 'select',
                    placeholder: '联网状态',
                    options: [
                        { label: '未联网', value: 0 },
                        { label: '已联网', value: 1 },

                    ]
                },
                {
                    prop: 'vehicleType',
                    type: 'select',
                    placeholder: '车型',
                    options: [
                        { label: '侧翻车-高箱', value: '0' },
                        { label: '侧翻车-低箱', value: '1' },

                    ]
                },
                {
                    prop: 'relate',
                    type: 'select',
                    placeholder: '关联关系',
                    options: [
                        { label: '自有', value: '0' },
                        { label: '临时', value: '1' },

                    ]
                },




                {
                    label: "创建时间", prop: "createTime", type: "daterangehms",
                    startPlaceholder: "起始时间",
                    endPlaceholder: "结束时间",
                    span: 6
                },
                {
                    prop: 'search',
                    type: 'button',
                    policy: ['system.log.query'],
                },
            ],
            tableData: [],
            tableColumn: [
                { label: "车牌号", prop: "vehicleNumber", fixed: 'left', width: 200},
                // review_status 审核状态0待审核1已通过2已驳回
                { label: "审核状态", prop: "reviewStatus", render: true },
                { label: "车辆状态", prop: "vehicleStatus", render: true },
                { label: "排放标准", prop: "emissionStandard", render: true},
                { label: "是否启用", prop: "isActive", render: true },
                { label: "行驶证号", prop: "drivingLicenseNumber", },
                { label: "使用性质", prop: "usageType", render: true},
                { label: "号牌颜色", prop: "vehicleColor", render: true},
                { label: "车辆类型", prop: "drivingVehicleType", render: true},
                { label: "车型", prop: "vehicleType", render: true},
                { label: "是否集装箱", prop: "isContainer", render: true},
                { label: "联网状态", prop: "networkStatus", render: true},
                { label: "关联物流公司(家)", prop: "relatedLogisticsCompanies", },
                { label: "关联关系", prop: "relate", render: true },
                { label: "创建时间", prop: "createTime", },
                { label: "创建人", prop: "createBy", },
                { label: "操作时间", prop: "updateTime", },
                { label: "操作人", prop: "updateBy", },



                {
                    label: '操作',
                    prop: 'action',
                    fixed: 'right',
                    type: 'button',
                    width: 170,
                    buttons: [
                        {
                            label: '查看',
                            type: 'text',
                            color: 'rgba(0, 118, 255, 1)',
                            method: 'handleDetail',
                        },
                        {
                            label: '编辑',
                            type: 'text',
                            color: 'rgba(0, 118, 255, 1)',
                            method: 'handleEdit',

                        },
                        {
                            label: '审核',
                            type: 'text',
                            color: 'rgba(0, 118, 255, 1)',
                            method: 'handleAudit',
                            hide: 'reviewStatus',
                            hideValue: [0],

                        },
                        {
                            label: '删除',
                            type: 'text',
                            color: '#ee3333',
                            method: 'handleDelete',

                        },
                    ],
                },

                //  {
                //     label: "操作",
                //     prop: "action",
                //     type: "button",
                //     hideTooLtip:true,
                //     width:180,
                //     button:[
                //         {
                //             label: "查看",
                //             type: "text",
                //             icon: "el-icon-view",
                //             method:`_detail${this.$options.name}`
                //         },
                //         {
                //             label: "通过",
                //             type: "text",
                //             icon: "el-icon-view",
                //             hide:'isCanTakeAudit',
                //             // hide:'canTakeAudit',
                //             hideValue:[false],
                //             policy:['Crm.CluePoolManage.TakeAudit'],
                //             method:`_auditSuccess${this.$options.name}`
                //         },
                //         {
                //             label: "驳回",
                //             type: "text",
                //             icon: "el-icon-view",
                //             hide:'isCanTakeAudit',
                //             // hide:'canTakeAudit',
                //             hideValue:[false],
                //             policy:['Crm.CluePoolManage.TakeAudit'],
                //             method:`_auditFail${this.$options.name}`
                //         },
                //     ]
                //  }   
            ],
            systemOptions: [
                { label: '1111', value: 1 },
                { label: '22221', value: 2 },

            ],
            total: 0,
            currentPage: 1,
            selectArr: [],
            allotVisile: false,
            allotModel: {},
            allotRule: {
                responsibleUserId: [
                    // { required: true, trigger: "blur", message: "必填" },
                    { validator: validateEmpty, required: true, trigger: "blur" }
                ],
            },
            dictRule: {

                reviewStatus: [{ required: true, trigger: "change", message: "必选" }],


            },
            userOptions: [],
            settingVisile: false,
            ruleModel: {},
            ruleRule: {
                autoRecycleEnable: [{ required: true, trigger: "blur", message: "必填" }],
                autoRecycleByNotFollowUpOverDays: [{ required: true, trigger: "blur", message: "必填" },
                { validator: validateNumberF, required: true, trigger: "blur" }],

                originalResponsibleUserTakeLimit: [{ required: true, trigger: "blur", message: "必填" }],
                originalResponsibleUserTakeLimitDays: [{ required: true, trigger: "blur", message: "必填" },
                { validator: validateNumberF, required: true, trigger: "blur" },
                ],
                takeLimit: [{ required: true, trigger: "blur", message: "必填" }],
                takeLimitByEveryDayNumbers: [{ required: true, trigger: "blur", message: "必填" },
                { validator: validateNumberF, required: true, trigger: "blur" },
                ],
            },
            detailVisible: false,
            detailId: '',
            openSeaClueId: '',
            status: null,
            isCanTakeAudit: null
        }
    },
    mounted() {
        this.getLogisticsVehicleInfoStatus()
        this.getQueryDictDetailByCodeWay('usageType') //使用性质
        this.getQueryDictDetailByCodeWay('emissionStandard')//排放标准
        this.getQueryDictDetailByCodeWay('vehicleColor')
        this.getQueryDictDetailByCodeWay('drivingVehicleType') //车辆类型
        
        this.getQueryDictDetailByCodeWay('vehicleType') //车型
     
        
        this.getVehicleInfoList()
        // 详情
        this.$bus.$on('handleDetail', rows => {

            this.$router.push({ path: `/logistics/vehicleInfor/detail/${rows.id}` })
        })
        // 编辑
        this.$bus.$on('handleEdit', rows => {
            this.$router.push({ path: `/logistics/vehicleInfor/update/${rows.id}` })

        })
        // 审核
        this.$bus.$on('handleAudit', rows => {
            this.auditVisile = true
            this.auditId = rows.id
            // this.$router.push({ path: `/system/msg/edit/${rows.id}` })
        })

        // 删除
        this.$bus.$on('handleDelete', rows => {
            this.$confirm('确定删除吗', '取消', {
                cancelButtonText: '取消',
                confirmButtonText: '确定',
                closeOnClickModal: false
            }).then(() => {
                //   console.log('确认');
                masterDataApi.delVehicleInfo(rows.id).then(res => {
                    if (res.code == 200) {
                        this.$message.success("删除成功")
                        this.getVehicleInfoList()
                    }
                })
            })
        })
    },
    methods: {
        getLogisticsVehicleInfoStatus(){
            masterDataApi.logisticsVehicleInfoStatus(

            ).then(res=>{    
                let arr = Object.keys(res)
                arr.map(
                    item=>{
                        this.searchData[0].options.map(iem=>{
                            if(item==iem.value){
                                iem.num = res[item]
                            }
                        
                        })
                        
                    }
                )
                
                })
        },
       // 字典值回显操作(value=>id)
        // 获取字典信息
        showByDict(dictCode,val){
            
           let arr1 =  this.searchData.map(item => {
                        if (item.prop == dictCode) {                          
                           let arr = item.options.filter(itm=>val==itm.value)                      
                           return  arr[0].label                                               
                        }
                    })
                    let arr2 = arr1.filter(item=>item!=null)
                    return arr2[0]


    //     let name = `${dictCode}Options`
    //    let arr = this.selectOptions[name].filter(item=>val==item.dictValue)
       
    },
        getQueryDictDetailByCodeWay(dictCode) {
            masterDataApi.getQueryDictDetailByCode(dictCode).then(res => {
                if (res.code == 200) {
                    // let name = `${dictCode}Options`
                    this.searchData.forEach(item => {
                        if (item.prop == dictCode) {
                            item.options = res.data.sysDictDataDetailList.map(itm => {
                                return {
                                    label: itm.dictValue,
                                    value: itm.id
                                }
                            })
                        }
                    })

                }
            })
        },
        exportWay() {

            this.download('logistics/vehicleInfo/export', {
                ...this.searchData
            }, `车辆信息_${new Date().getTime()}.xlsx`)
        },
        // 批量操作
        handleCommand(val) {
            if (this.selectArr.length == 0) {
                this.$message.warning("请先勾选")
                return
            } else {
                const len = this.selectArr.length
                let title = '启用'
                let content = '确定要启用吗？'

                switch (val) {
                    // 启用
                    case 'import':
                        if (len >= 2) {
                            title = '批量启用'
                            content = `已选择${len}项，确定要启用吗？`
                        }
                        this.setEnabled(
                            {
                                isActive: 1,
                                content,
                                title,
                            }
                        )
                        break;

                    case 'export':
                        title = '禁用'
                        content = '确定要禁用吗？'
                        if (len >= 2) {
                            title = '批量禁用'
                            content = `已选择${len}项，确定要禁用吗？`
                        }
                        this.setEnabled(
                            {
                                isActive: 0,
                                content,
                                title,
                            }
                        )
                        break;
                    default:
                        //删除
                        this.setDel()
                        break;
                }
            }

        },

        // 启用操作
        setEnabled(obj) {
            // let params = {
            //     ids: this.selectArr.map(item => item.id).join(','),
            //     isEnabled: obj.isEnabled
            // }
            let paramsList = this.selectArr.map(item => {
                return {
                    id: item.id,
                    isActive: obj.isActive
                }
            })

            this.$confirm(obj.content, obj.title, {
                cancelButtonText: '取消',
                confirmButtonText: '确定',
                closeOnClickModal: false
            }).then(() => {

                masterDataApi.updateVehicleInfoList(paramsList).then(res => {
                    if (!res.error) {
                        this.$message.success("操作成功")
                        this.getVehicleInfoList()
                        this.$refs.tablePage.clearSelection()
                    }
                })
            })
        },
        setDel() {
            if (this.selectArr.length == 0) {
                this.$message.warning("请先勾选")
                return
            }
            let content = '确定删除吗'
            let title = '删除'
            if (this.selectArr.length >= 2) {
                title = '批量删除'
                content = `已选择${this.selectArr.length}项，确定要删除吗？`
            }
            this.$confirm(content, title, {
                cancelButtonText: '取消',
                confirmButtonText: '确定',
                closeOnClickModal: false
            }).then(() => {
                //   console.log('确认');
                let ids = this.selectArr.map(item => item.id).join(',');

                masterDataApi.delVehicleInfo(ids).then(res => {
                    if (res.code == 200) {
                        this.$message.success("操作成功")
                        debugger
                        this.getVehicleInfoList()
                        this.$refs.tablePage.clearSelection()
                    }
                })
            })
        },
        // 创建司机
        add() {
            this.$router.push({ path: `/logistics/vehicleInfor/insert` })

        },
        handleAddSubmit() {
            this.$refs.dictForm.validate(valid => {
                if (valid) {
                    console.log('handleAddSubmit 验证通过', this.dictModel);
                    if (!this.isEdit) {
                        addDict(this.dictModel).then(res => {
                            if (!res.error) {
                                console.log('addDict', res);
                                this.dictModel = {
                                    items: []
                                }
                                this.$message.success("添加字典成功")
                                this.addVisile = false;
                                this.getDictList()
                            }
                        })
                    } else {
                        editDict(this.dictModel).then(res => {
                            if (!res.error) {
                                console.log('editDict', res);
                                this.dictModel = {
                                    items: []
                                }
                                this.$message.success("编辑字典成功")
                                this.addVisile = false;
                                this.getDictList()
                            }
                        })
                    }
                } else {
                    this.$message.warning("请检查字典信息")
                    return false
                }
            })
        },
        handleAddCancle() {

            this.dictModel = this.$options.data().dictModel
            this.resetForm("dictForm")
            this.addVisile = false;
        },
        // 审核操作
        handleAuditSubmit() {
            this.$refs.auditParams.validate(valid => {
                if (valid) {

                    masterDataApi.vehicleInfoAudited({
                        ...this.auditParams,
                        id: this.auditId
                    }).then(res => {
                        if (res.code == 200) {
                            this.auditVisile = false;
                            this.auditParams == this.$options.data().auditParams
                            this.$message.success("审核成功")

                            this.getVehicleInfoList()
                        }
                    })
                } else {
                    this.$message.warning("请检查信息")
                    return false
                }
            })
            // masterDataApi.vehicleInfoAudited
        },
        handleAuditCancle() {
            this.auditParams = this.$options.data().auditParams
            this.resetForm("auditParams")
            this.auditVisile = false;
        },
        getVehicleInfoList() {
            // addDateRange
            let { pageSize } = this.$refs.tablePage;
            let params = {

                ...this.searchModel,
                pageSize: pageSize,
                pageNum: this.currentPage


            }
            let obj = addDateRange(params, this.searchModel.loginTime)
            delete obj.loginTime



            masterDataApi.vehicleInfoList(obj).then(res => {
                if (!res.error) {

                    this.total = res.total;
                    this.tableData = res.rows

                }
            })
        },
        selectable(row, index) {
            return true
        },

        handleSearchSubmit() {
            this.currentPage = 1;
            this.getVehicleInfoList()
        },
        handleSearchReset() {
            this.currentPage = 1;
            this.$refs.tablePage.clearSelection()
            this.getVehicleInfoList()
        },
        handleSizeChange(v) {
            this.pageSize = v;
            this.currentPage = 1;
            this.getVehicleInfoList()
        },
        handleCurrentChange(v) {
            this.currentPage = v;
            this.getVehicleInfoList()
        },
        handleSelectionChange(v) {
            console.log('handleSelectionChange', v);
            this.selectArr = v
        },
        allot() {
            this.$modal.confirm('是否确认清空所有登录日志数据项？').then(function () {
                return cleanLogininfor();
            }).then(() => {
                this.getVehicleInfoList();
                this.$modal.msgSuccess("清空成功");
            }).catch(() => { });
        },



        deleteCustomer() {
            if (this.selectArr.length == 0) {
                this.$message.warning("请先勾选日志")
                return
            }
            this.$confirm('确定删除吗', '删除', {
                cancelButtonText: '取消',
                confirmButtonText: '确定',
                closeOnClickModal: false
            }).then(() => {
                //   console.log('确认');
                let params = {
                    ids: this.selectArr.map(item => item.infoId),
                }
                delLogininfor(params.ids).then(res => {
                    if (!res.error) {
                        this.$message.success("操作成功")
                        this.getVehicleInfoList()
                        this.$refs.tablePage.clearSelection()
                    }
                })
            })
        },
        gethtml(value) {
            if (value == null) {
                return;
            }
            var list = value.split(',');
            var resultStr = ""
            list.forEach(item => {
                if (item.includes("高") || item.includes("重要")) {
                    resultStr = resultStr + "<span style='color:#EE3333'>" + item + "</span>,";
                }
                else {
                    resultStr = resultStr + item + ",";
                }
            })
            if (resultStr != "") {
                return resultStr.slice(0, -1);
            }
        },
        showSettign() {
            getOpenSeaSetting().then(res => {
                if (!res.error) {
                    console.log('getOpenSeaSetting', res);
                    this.ruleModel = res;
                    this.settingVisile = true;
                }
            })
        },
        handleSettingSubmit() {
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    console.log('ruleModel', this.ruleModel);
                    putOpenSeaStting(this.ruleModel).then(res => {
                        if (!res.error) {
                            this.$message.success("保存设置成功")
                            this.settingVisile = false;
                        }
                    })
                } else {
                    return false
                }
            })
        },
        handleSettingCancle() {
            this.settingVisile = false;
        },
        detailClose() {
            this.detailVisible = false;
            this.getVehicleInfoList()
        },
        handleAllot() {
            this.allotVisile = true;
        },

        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
    },
    destroyed() {
        this.$bus.$off('handleDetail')
        this.$bus.$off('handleDelete')
        this.$bus.$off('handleEdit')
        this.$bus.$off('handleAudit')


    },
}
</script>
    
<style lang="scss" scoped>
.vehicleInfor_block {

    // padding: 0 .2rem .2rem;
    .top {
        background-color: #fff;
        padding: 0 .3rem;
    }

    .bottom {
        .btn_area {
            margin-bottom: 0.2rem;
            margin-left: 0.3rem;
        }

        background-color: #fff;
        margin-top: 0.2rem;
        padding: 0.2rem 0rem;


    }




    .green {
        color: #2CAD00;
    }

    .orage {
        color: #EE7533;
    }

    .blue {
        color: #0076FF;
    }

    .red {
        color: #ff3333;
    }
}
</style>